package c.f.d.a.a.a.a;

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public final class a {
    public static final String a = "a";

    public static byte[] a(byte[] bArr, byte[] bArr2) {
        Object obj;
        String str;
        StringBuilder g;
        byte[] a = c.f.d.a.a.a.d.a.a(16);
        if (bArr == null || bArr.length == 0 || bArr2.length < 16 || a.length < 16) {
            c.f.a.a.a.a.m(a, "cbc encrypt param is not right");
            obj = new byte[0];
        } else {
            SecretKeySpec secretKeySpec = new SecretKeySpec(bArr2, "AES");
            try {
                Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
                instance.init(1, secretKeySpec, new IvParameterSpec(a));
                obj = instance.doFinal(bArr);
            } catch (NoSuchAlgorithmException e) {
                str = a;
                g = c.b.a.a.a.g("NoSuchAlgorithmException: ");
                g.append(e.getMessage());
                c.f.a.a.a.a.m(str, g.toString());
            } catch (NoSuchPaddingException e2) {
                str = a;
                g = c.b.a.a.a.g("NoSuchPaddingException: ");
                g.append(e2.getMessage());
                c.f.a.a.a.a.m(str, g.toString());
            } catch (InvalidKeyException e3) {
                str = a;
                g = c.b.a.a.a.g("InvalidKeyException: ");
                g.append(e3.getMessage());
                c.f.a.a.a.a.m(str, g.toString());
            } catch (InvalidAlgorithmParameterException e4) {
                str = a;
                g = c.b.a.a.a.g("InvalidAlgorithmParameterException: ");
                g.append(e4.getMessage());
                c.f.a.a.a.a.m(str, g.toString());
            } catch (IllegalBlockSizeException e5) {
                str = a;
                g = c.b.a.a.a.g("IllegalBlockSizeException: ");
                g.append(e5.getMessage());
                c.f.a.a.a.a.m(str, g.toString());
            } catch (BadPaddingException e6) {
                str = a;
                g = c.b.a.a.a.g("BadPaddingException: ");
                g.append(e6.getMessage());
                c.f.a.a.a.a.m(str, g.toString());
            }
        }
        bArr2 = new byte[(a.length + obj.length)];
        System.arraycopy(a, 0, bArr2, 0, a.length);
        System.arraycopy(obj, 0, bArr2, a.length, obj.length);
        return bArr2;
        obj = new byte[0];
        bArr2 = new byte[(a.length + obj.length)];
        System.arraycopy(a, 0, bArr2, 0, a.length);
        System.arraycopy(obj, 0, bArr2, a.length, obj.length);
        return bArr2;
    }
}
